package com.atguigu.gmall.product.init;

import com.atguigu.gmall.product.service.SkuImageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplicationRunListener;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

@Slf4j
public class InitListener implements SpringApplicationRunListener {

    @Autowired
    SkuImageService skuImageService;

    //构造器
    public InitListener(SpringBootApplication application, String[] args) {
        log.info("监听器对象创建： application:{}, args:{}",application,args);
        this.springBootApplication = application;
    }

    private SpringBootApplication springBootApplication;

    @Override
    public void starting() {
        log.info("监听到项目starting");
    }

    @Override
    public void started(ConfigurableApplicationContext context) {
        log.info("监听到项目started + skuImageService = " + skuImageService); //skuImageService = null
    }
}
